mod get;
mod post;

use std::sync::{Arc, Mutex};

use model_graph_types::container::workflow::{
    HttpStatement, WorkflowBlockExecuteResult, WorkflowHttpMethod,
};

use crate::workflow::context::WorkflowContext;

pub async fn execute(
    statement: &HttpStatement,
    context: Arc<Mutex<WorkflowContext>>,
) -> anyhow::Result<WorkflowBlockExecuteResult> {
    //获取请求的方法
    let method = &statement.method;
    match method {
        WorkflowHttpMethod::Get => {
            //Get
            return get::execute(statement, context).await;
        }
        WorkflowHttpMethod::Post => {
            //POST
            return post::execute(statement, context).await;
        }
        _ => {}
    }
    Ok(WorkflowBlockExecuteResult::succeed())
}
